<% content_for :css do %>
  <%= stylesheet_link_tag 'index','factories_index' %>
<% end %>
<% content_for :title do %>-品牌工厂<% end %>
<div class='body'>
  <div class='top'>
    <div class='title'>
      <b>基础数据</b><span>品牌工厂</span>
    </div>
  </div>
  <div class="search">
    <%= form_tag factories_url,
          :method => :get do %> 
      <%= hidden_field_tag :target, params[:target] %>
      <%= text_field_tag :key_words, params[:key_words] ,:class => :search, :onfocus => 'select()' %>
      <%= submit_tag '查找工厂', :class => :bb %>
      <%= link_to '新增工厂', new_factory_url,  :class => :new %>
    <% end %>
  </div>  
  <div class="page">
    <div class="total_currnet"><p>共</p><b><%= @factories.size %></b><p>间工厂</p></div>
  </div>      
  <div class="index">  
    <% @factories.each do |factory| %>
    <div id='factory_<%= factory.id %>' class="monomer">
      <div class="content">
        <div class="title">
          <div class="name">
            <b><%= factory.name %></b>
          </div>
          <div class="information">
            <p class="message">
              <%= factory.address %>
            </p>
            <p class="statistics">
              <%= factory.link_phone %>
            </p>
            <p class="statistics">
              <%= factory.link_man %>
            </p>
          </div>
          <div class="information">
            <p class="statistics">
              <b>email:</b> <%= link_to_function factory.email, "mail_to:#{factory.email}" %>
            </p>
            <p class="statistics">
              <b>qq:</b> <%= factory.qq %>
            </p>
            <p class="statistics">
              <b>msn:</b> <%= factory.msn %>
            </p>
          </div>
        </div>      
        <div class="article">
          <%= factory.remark %>
        </div>
      </div>
      <div class="operate">
        <%= link_to '修改',edit_factory_url(factory), :class => 'button' %>
        <% if factory.status.visible? %>
          <% if factory.can_be_hidden? %>
          <%= link_to '隐藏',
                hide_factory_url(factory),
                :confirm => '确认要设置为隐藏吗？',
                :method => :put,
                :class => 'button',
                :id => "hide_factory_#{factory.id}_link"
           %>
           <% else %>
           <span class='none' title='请先隐藏从属材质和家具款式后，方可隐藏该工厂'>隐藏</span>
           <% end %>
         <% else %>
         <%= link_to '可见',
              visible_factory_url(factory),
              :confirm => '确认要设置为可见吗？',
              :method => :put,
              :class => 'button',
              :id => "visible_factory_#{factory.id}_link"
         %>
         <% end %>
      </div>
    </div>
    <% end %>
  </div>
  <div class="page">
    <div class="total_currnet"><p>共</p><b><%= @factories.size %></b><p>间工厂</p></div>
  </div>        
</div>

        